Block-Based Fast Image Compression

ABSTRACT

Systems and methods for block-based fast image compression are described. In one aspect, a digital image is segmented into multiple blocks. A respective set of statistical characteristics is identified for each of the segmented blocks. Each of the blocks is encoded with a particular encoding algorithm of multiple encoding algorithms. The particular encoding algorithm that is used to encode a particular block segmented from the digital image is selected to efficiently encode the block in view of statistical characteristics associated with the block. Thus, blocks of different block types may be encoded with different encoding algorithms.

BACKGROUND

A digital compound image includes mixed raster content (MRC) such assome combination of text and picture image(s) and/or graphic(s).Exemplary compound images include, for example, screen captures,electronic newspapers and magazines, web pages, etc. With the widespreaduse of digital devices such as personal computers, digital cameras,imaging-enabled cell phones, etc., availability and sharing of compoundimages is becoming more common. To store and communicate digitalcompound images, a compound image is typically compressed (encoded) toreduce size. The quality requirement of compound image encoding isgenerally different from the quality requirement for encoding imagesthat do not contain text (a general/non-compound image). This is becausesensitivity of the human eyes for natural images (e.g., captured images,etc.), texture, text and other sharp edges, is often different. Whilethere may be several acceptable levels of pure image and texturequality, a user will typically not accept text quality that is not clearenough to read. This is because text typically contains high-levelsemantic information.

The Lempel-Ziv encoding algorithm is designed to compress pure textimages (e.g., images with only text on the pure color background). JPEGimage encoding is suitable for images that include only pictures and notext. One reason for this is because JPEG encoding algorithms typicallydo not perform very well when encoding text. Additionally, existingcompound image encoding techniques such as layered coding techniques donot typically perform well when encoding pure text images. Layeredencoding techniques are also very processing intensive, making themgenerally unsuitable for real-time applications that demand constantbit-rate encoding and rate allocation (e.g., for streaming compoundimage content). Moreover, conventional block-based compound imageencoding typically compress text blocks using JPEG-LS and picture blocksusing JPEG. Such block-based encoding techniques fail to perform wellwhen encoding compound images that include some combination of text andpicture image(s).

SUMMARY

This Summary is provided to introduce a selection of concepts in asimplified form that are further described below in the detaileddescription. This Summary is not intended to identify key features oressential features of the claimed subject matter, nor is it intended tobe used as an aid in determining the scope of the claimed subjectmatter.

In view of the above, systems and methods for block-based fast imagecompression are described. In one aspect, a digital image is segmentedinto multiple blocks. A respective set of statistical characteristics isidentified for each of the segmented blocks. Each of the blocks isencoded with a particular encoding algorithm of multiple encodingalgorithms. The particular encoding algorithm that is used to encode aparticular block segmented from the digital image is selected toefficiently encode the block in view of statistical characteristicsassociated with the block. Thus, blocks of different block types may beencoded with different encoding algorithms.

BRIEF DESCRIPTION OF THE DRAWINGS

In the Figures, the left-most digit of a component reference numberidentifies the particular Figure in which the component first appears.

FIG. 1 shows an exemplary system for block-based fast image compression,according to one embodiment.

FIG. 2 shows an exemplary set of block gradient histograms associatedwith blocks segmented from a digital image, according to one embodiment.

FIG. 3 shows an exemplary procedure for classifying block type of blockssegmented from a digital image, according to one embodiment.

FIG. 4 shows exemplary text block coding contexts, according to oneembodiment.

FIG. 5 shows exemplary procedure for selecting an appropriate codingalgorithm for each block segmented from a digital image, according toone embodiment.

FIG. 6 shows an exemplary procedure for block-based fast imagecompression, according to one embodiment.

DETAILED DESCRIPTION

Overview

Systems and methods for block-based fast image compression aredescribed. The systems and methods divide a digital image (a compound ornon-compound image) into blocks. Each of the blocks is then evaluated inview of statistical and other characteristics of the block to classifythe block as a particular block type. In this implementation, blocktypes include, for example, smooth, text, hybrid, and picture blocktypes, although other block types could be used. The systems and methodsselect a respective encoding algorithm of multiple encoding algorithmsto encode each block to maximize compression performance in view of theblock's block classification type and quality and rate constraints.

These and other aspects of systems and methods for block-based fastimage compression are now described in greater detail.

An Exemplary System

Although not required, the systems and methods for block-based fastimage compression are described in the general context ofcomputer-executable instructions (program modules) being executed by acomputing device such as a personal computer. Program modules generallyinclude routines, programs, objects, components, data structures, etc.,that perform particular tasks or implement particular abstract datatypes. While the systems and methods are described in the foregoingcontext, acts and operations described hereinafter may also beimplemented in hardware.

FIG. 1 shows an exemplary system 100 for block-based fast imagecompression, according to one embodiment. System 100 includes computingdevice 102. Computing device 102 represents any type of computing devicesuch as a personal computer, a server, a laptop, a handheld or mobilecomputing device, a small form factor device, a digital cameral, etc.Computing device 102 includes one or more processing units 104 coupledto memory 106. Memory 106 includes system memory and any other type ofmemory coupled to computing device 102. System memory (e.g., RAM andROM) includes computer-program modules (“program modules”) 108 andprogram data 110. Processor(s) 104 fetch and execute computer-programinstructions from respective ones of the program modules 108. Programmodules 108 include block-based fast image compression module 112(“encoder 112”) for encoding image content 114 (compound and/ornon-compound images) to generate compressed images 116. Program modules108 also include “other program modules” 118 such as an operatingsystem, a decoder to decode a compressed image 116, application(s) thatleverage aspects of block-based fast image compression module 112,and/or so on. The decoder decodes a compressed image using a reverse setof operations used to generate the compressed image 116, as discussedbelow. Although encoder 112 is shown on the same device 102 as a decoder118, these program modules do not need to exist on the same computingdevice and may be part of different computing devices. In this scenario,an image 114 can be encoded on a first device 102 and decoded on adifferent device 102.

Encoder 112 segments (divides) an image 114 into blocks 120. In oneimplementation, each block 120 is 16×16 pixels. Size of the segmentedblocks is arbitrary and can vary across blocks or represent a samesegment size. BFIC model 112 then classifies each block 120 as one ofmultiple different block types based at least on the block's respectivestatistical characteristics. In this implementation, the different blocktypes include smooth, text, hybrid, and picture block types. Thestatistical characteristics include, for example, directional gradientdistributions associated with each pixel in a block 120. For each block120, encoder 112 selects a particular compression algorithm to encodethe block 120 in view of the block's type classification, rateconstraint(s), and quality parameters. Encoder 112 used the selectedencoding algorithm to encode the block 120. This is performed for eachsegmented block to generate a corresponding compressed image 116.

Specifics of how encoder 112 classifies blocks 120 into one of multiplepossible blocks types are now described.

Exemplary Block Classification

Encoder 112 calculates gradients 122 and generates gradient histogram(s)124 for each block 120 to identify statistical characteristics for eachblock. A gradient is an absolute difference between a pixel and aneighboring pixel. With the exception of boundary pixels, each pixel ina block 120 has 8 neighboring pixels. To generate gradients 122 for ablock 120, encoder 112 calculates 8 directional gradients for eachnon-boundary pixel in the block 120. In this implementation, and whenneighboring pixels are not in the same block, gradients of boundarypixels are not calculated. In another limitation, gradients of boundarypixels are calculated in view of (by borrowing) pixels in other blocks.To determine distributions of gradient values, encoder 112 thresholds(independent of gradient direction) the gradients 122 for a block 120 toclassify and group gradients 122. For example, encoder 112 groupsgradients 122 that are less than threshold G₁ (e.g. G₁=6) into alow-gradient class, greater than a threshold G₂ (e.g. G₂=36) into ahigh-gradient class, and in between G₁ and G₂ into a mid-gradient class.Encoder 112 creates a respective gradient histogram 124 for each block120 based on that block's gradient distributions and pixel color (e.g.,0-255).

FIG. 2 shows an exemplary set of gradient histograms 124, according toone embodiment. In these examples, horizontal coordinates representpixel gray values (e.g., 0-255), and vertical coordinates representpixels counts. For example, when gradient of a pixel is low, then thecount of low gradient at the pixel gray value increases one. In FIG. 2,blocks 120 of different type exhibit different gradient-histogramdistributions. For instance, FIG. 1(a) represents a histogram 124 of ablock 120 that has been classified as a text block type; FIG. 1(b)represents a histogram 124 of a block 120 that has been classified as apicture block type; and FIG. 1(c) represents a histogram 124 of a block120 that has been classified as a hybrid block type. Based on thegradient distributions exhibited by each block 120, encoder 112classifies the block 120 as a smooth, text, hybrid, or picture blocktype. A histogram 124 representing a smooth block type will typicallyexhibit only low gradient pixels and show one peak corresponding to alow-gradient class pixel distribution. A histogram 124 representing atext block type will typically exhibit several peaks with respect tolow-gradient high-gradient pixel class distributions. A histogram 124for a picture block type will typically exhibit only a few mid-gradientclass pixels. If a block 120 contains large numbers of high-gradientclassified pixels and mid-gradient classified pixels, encoder 112classifies the block 120 as a hybrid block type.

FIG. 3 shows an exemplary procedure 300 for classifying block type ofblocks segmented from a digital image, according to one embodiment. Inthis implementation, block types include, for example, picture, smooth,text, and hybrid block types, although other block classifications couldbe used. For purposes of exemplary description and illustration, theoperations of the procedure are described with respect to the componentsof FIG. 1. At block 302, and in view of block information associatedwith a block 120, encoder 112 (FIG. 1) determines whether the count ofhigh and low gradient classified pixels is less than a first thresholdT₁. (The block information includes information associated with theblock 120 such as a corresponding histogram 124, color information,etc.) If so, at block 304, encoder 112 classifies the particular block120 as a picture block. Otherwise, at block 306, encoder 112 determineswhether a number of high-gradient pixels is less than a second thresholdT₂, and whether the number of low-gradient pixels is greater than athird threshold T₃. If so, at block 308, encoder 112 determines whetherthe gray level range of the block 120 is less than a fourth thresholdT₄. If the results of block 308 are positive, at block 310, encoder 112indicates that the block 120 is a smooth block. If the results of block308 are negative, at block 312, encoder 112 indicates that the block 120is a picture block.

If the results of block 306 were negative, at block 314, encoder 112determines if the major color number associated with the block 120 isless than a fifth threshold T₅. As discussed below in the section titled“Exemplary Text Block Coding” a block 120 may include colors, of whichone or more may be classified as more dominant (major) than the othercolors. Encoder 112 assigns numerals to these major colors. If theresults of block 314 are positive, encoder 112 at block 316 determineswhether the number of high-gradient pixels associated with the block 120are less than a sixth threshold T₆. If so, at block 318, encoder 112indicates that the block 120 is a text block. Otherwise, at block 320,encoder 112 indicates that the block 120 is a picture block.

If the results of block 314 were negative (i.e., the major color numberis less than the fifth threshold), at block 322, encoder 112 determineswhether the number of high-gradient classified pixels in the block 120is greater than a seventh threshold T₇. If so, at block 324, encoder 112classifies the block 120 as a hybrid block. Otherwise, at block 326,encoder 112 indicates that the block 120 is a picture block.

In the above examples of the FIG. 3, thresholds T₁ through T₇ areconfigurable.

Exemplary Digital Image Block Coding

Blocks 120 of different type are distinct in nature and have differentstatistics distributions, as illustrated above with respect tohistograms 124. A smooth block 120 (a block 120 classified as a smoothblock) is typically very flat and dominated by one kind of color. A textblock 120 is more compact in spatial domain than that in Discrete CosineTransfer (DCT) domain. The energy of a picture block 120 is mainlyconcentrated on low frequency coefficients when they are DCTtransformed. A hybrid block 120 containing mixed text and picture imagescannot be compactly represented both in spatial and frequency domain.Because of the different characteristics of different block types,encoder 112 implements a different respective encoding algorithm tocompress blocks 120 of different block type. In this implementation,encoder 112 implements four different encoding algorithms to effectivelycompress the different block types.

Exemplary Smooth Block Coding

Smooth blocks 120 are dominated by one color and their gray level rangeis limited to the given threshold. In view of this, encoder 112quantizes all colors in smooth blocks 120 to the most frequent color,which in this implementation, is coded using an arithmetic coder portionof encoder 112.

Exemplary Text Block Coding

Text blocks 120 are typically dominated by several major colors. In viewof this, encoder 112 selects colors with frequency above a giventhreshold as major colors (i.e., colors dominating the block 120). Ifthere are more than four colors satisfying this requirement, encoder 112selects only the first four colors with largest number in acorresponding luminance histogram as major colors. Encoder 112 quantizesthe colors close to major colors within a given distance threshold tocorresponding major colors. TABLE 1 shows an exemplary algorithm toquantize certain colors to major colors. TABLE 1 EXEMPLARY COLORQUANTIZATION Find first four major colors { M₀,M₁,M₂,M₃ }; FOR eachpixel P_(i) FOR each major color j IF |P_(i) − M_(j)| < Th for some j,THEN P_(i) := M_(j) ; ENDIF; ENDFOR; ENDFOR;As shown in TABLE 1, encoder 112 first converts every pixel's color inthe text block 120 to a color index. In this implementation, the majorcolors in the block 120 are indexed by 0, 1, 2, and 3 respectively. Allthe other colors are converted by BFIC model 112 to index 4. The majorcolors in each block are recorded.

Encoder 112 scans and compresses the color index for the text block 112in a raster scanning order and the current pixel index is coded based onits causal neighbors (as shown in FIG. 4) to exploit the spatialrelevance in order to improve coding efficiency.

FIG. 4 shows exemplary text block coding contexts, according to oneembodiment. Referring to FIG. 4, context is generally described as P(NW,N, W), where NW, N, W are the coded neighboring index, and the functionP is the possibility of certain value of the current index. P is a kindof prediction to the current index from neighboring indexes. In thisexample, “X” is current pixel to be coded. Each neighbor pixel mayrepresent one of five possible different index values. As a result,there are total 5³=125 contexts for coding the current pixel “X”.Encoder 112 codes the current pixel index using an arithmetic coderusing the context specified by its three causal neighbors [NW, N, W]. Ifthe current pixel index is 4, the pixel value is also coded using anarithmetic coder.

TABLE 2 shows an exemplary algorithm for text block coding, according toone embodiment. TABLE 2 EXEMPLARY TEXT BLOCK CODING Quantize the blockusing Color Quantization; Convert the block pixels to index; FOR row = 1to last row FOR column = 1 to last column Get index for current pixel;/*generate Context for current pixel*/ context := NW*25+N*5+W; Codecurrent pixel index using the context; IF pixel index is 4 (othercolors) THEN code the current pixel value; ENDIF ENDFOR ENDFOR

Exemplary Hybrid Block Coding

Hybrid blocks 120 contain mixed text and pictures. There are strong highfrequency signals due to text edges and DCT transform is only effectiveto compact the energy of low frequency signals, so the energy in DCTdomain of hybrid block is very diverse and hard to code. If hybridblocks are compressed with DCT block transform based coding such asJPEG, the resulting compressed image will suffer from ringing effectsaround the text due to large quantization step for those high frequencycomponents. Wavelet-based schemes such as JPEG-2 fail to compress hybridblocks effectively. While hybrid blocks are compressed with documentimage algorithms, the coding performance is too low to be acceptable.One solution to this problem is layered coding, wherein BFIC model 112separates text and pictures in each block 120 into different layers andindependently codes each respective layer.

In this implementation, BFIC model 112 implements a Haar wavelet basedcoding algorithm for hybrid blocks 120, although other encodingalgorithms could also be used. Short wavelet bases are helpful to reducethe ringing effect around text (edge), and longer bases are good toimprove the coding performance of the picture images. As a tradeoffbetween two requirements, Haar wavelet is utilized to code hybridblocks. Use of Haar wavelets can effectively remove any “ringing effect”on resulting compressed image(s) 116 that comprise text. Its codingperformance outperforms other coding algorithms both inpeak-signal-to-noise-ratio (PSNR) and visual quality.

Encoder 112 first transforms a hybrid block 120 using Haar wavelets. Inthis implementation, only one level Haar wavelet transform is utilizedfor this transformation because multilevel Haar wavelet transforms willgenerally produce long wavelet bases not suitable for hybrid blocks 120.The wavelet coefficients are then coded by a simple arithmetic coder.The coefficients of different sub-bands are coded using differentcontexts. The simple Haar wavelet algorithm can significantly improvethe visual quality and PSNR of compressed images 116 resulting fromhybrid blocks 120.

Exemplary Picture Block Coding

JPEG has been proved to be an effective low complexity algorithm tocompress picture images. Encoder 112 implements a JPEG-like algorithm tocompress picture blocks 120. However, in contrast to conventional JPEGalgorithms, encoder 112 skips blocks 120 of other types in thisblock-based scheme.

Exemplary Quality-Based Rate Allocation

Mode Selection

Encoder 112 determines the proper coding algorithm (mode selection) foreach block 120 under a specified rate constraint. In thisimplementation, this is accomplished by using a quality-biased ratedistortion optimization (QRDO) technique to substantially guarantee thequality of text in a compressed image 116 resulting from a compoundimage 114. The problem of optimal rate allocation is formulated asfollows: $\begin{matrix}{{{\min\left( {\sum\limits_{i}{\alpha_{i}D_{i,{x{(i)}}}}} \right)}\quad,\quad{{{subject}\quad{to}\quad{\sum\limits_{i}R_{i,{x{(i)}}}}} \leq R_{0}}}{{x(i)} \in \left\{ {{smooth},{text},{picture},{hybrid}} \right\}}} & (1)\end{matrix}$where i indicates the i-th block 120 and α_(i) is a quality-weightfactor, x(i) is the selected coding mode. Here α_(i) is evaluated as:$\begin{matrix}{\alpha_{i} = \left\{ \begin{matrix}{C_{hg}/T_{hg}} & {{for}\quad{text}\text{/}{hybrid}\quad{block}} \\1.0 & {{for}\quad{smooth}\text{/}{picture}\quad{block}}\end{matrix} \right.} & (2)\end{matrix}$where C_(hg) represents the high-gradient count of this block 120 andT_(hg) is a threshold. Note that this factor is determined during theblock classification process discussed above. This factor remains thesame for each block 120 independent of block type. In thisimplementation, T_(hg) is set as 0.1 to ensure that for most text blocks120 the factor α_(i) is larger than 1.0.

Using Lagrangian optimization, for each block we have to minimize thecost function (cost is the sum of weighting distortions and used bits):J _(i)=α_(i) D _(i,x(i)) λR _(i,x(i))  (3)to choose the best mode x*(i). In general, if more bits are used incoding a image, the reconstructed quality is better. To reducedistortion, bits can be increased, but this does not represent theoptimal solution. The optimal target is to minimize the combination ofdistortions and bits. One issue is how to determine the value of λ tosatisfy the given rate constraint.

Rate-Distortion (R-D) optimized mode selection can achieve the optimalcoding performance subject to a specified rate constraint. To this end,encoder 112 sets the parameter λ in (3). Because evaluation of λ can bevery computation-intensive in view of a given a rate constraint R₀,encoder 112 implements an approximated algorithm to determine theLagrangian parameter λ. In this approximation algorithm, qualityparameters for picture coder and hybrid coder operations (discussedabove) are evaluated in view of the rate constraint. Encoder 112utilizes the slopes of the R-D curves of the two flexible coders toestimate λ and make the mode selection. It is possible that the totalrate at this point may not satisfy the rate constraint. In thisscenario, encoder 112 changes the quality parameters and estimates a newλ, and again select mode for each block. These operations are iterateduntil the rate constraint is satisfied and minimum distortion ismaintained without change for a certain period.

Modeling and Quality Parameters Setting

Modeling can help greatly in computations for rate-distortion tradeoffand it has been well studied in rate-control works for video coding.Exponential approximation is proper for both rate and distortion, thatisD(Q)≈AQ ^(α) , R(Q)≈BQ ^(β)  (4)where Q is the quantization step, and A, B, α>0, β<0 are parameters thatdepend on the characteristics of the block 120. According to the QRDOtechnique, distortion is replaced with weighted distortion, i.e.D_(i)′=α_(i)D_(i),  (5)wherein α_(i) is the quality-weight factor defined in (2). Then we useminimize-MSE fitting for both hybrid coder and cont-tone (picture) coderto solve the parameters in (4). So, derived from constant slope policy,the following is determined: $\begin{matrix}{\lambda = {{{- \frac{A_{h}}{B_{h}}}\frac{\alpha_{h}}{\beta_{h}}Q_{h}^{\alpha_{h} - \beta_{h}}} = {{- \frac{A_{c}}{B_{c}}}\frac{\alpha_{c}}{\beta_{c}}Q_{c}^{\alpha_{c} - \beta_{c}}}}} & (6)\end{matrix}$which can calculate the Lagrangian parameter λ for mode selection. Herethe subscript h and c indicate hybrid and picture blocks. Additionally,N _(h) R _(h) +N _(c) R _(c) ≦R′ ₀′  (7)where N_(h) and N_(c) represent the numbers of hybrid and pictureblocks, R_(h) and R_(c) correspond to average rates of hybrid andpicture blocks, and R₀′ means the rate constraint of hybrid and pictureblocks 120, it equals the difference of R₀ and the rate consumed bysmooth and text blocks 120. We assume that the total-rate constraint ishigh enough so that R₀′ is reasonable. So now, by combining (4), (6) and(7), Q_(h) and Q_(c) can be easily solved, and by (6) an estimated valueof the Lagrangian parameter λ for mode selection is also determined.

FIG. 5 shows exemplary procedure 500 for selecting an appropriate codingalgorithm for each block segmented from a digital image, according toone embodiment. For purposes of the exemplary description, theoperations of the procedure are described with respect to the componentsof FIG. 1. At block 502, encoder 112, in view of block information,selects a coding mode based on block type. The block informationincludes for example, information associated with a block 120. Thisinformation includes block 120 block type. At block 504, encoder 112, inview of a rate constraint, calculates quality parameters and estimates aLangrangian parameter. At block 506, encoder 112 selects the coding modebased on to the calculated and estimated parameters. At block 508,encoder 112 determines whether the rate constraint is satisfied andminimum distortion is maintained without change for a period of time. Ifnot, the operations continue at block 504, as discussed above, until theconditions are achieved.

An Exemplary Procedure

FIG. 6 shows an exemplary procedure 600 for block-based fast imagecompression, according to one embodiment. For purposes of exemplaryillustration and description, the operations of the procedure aredescribed with respect to components of FIG. 1. At block 602, encoder112 segments a digital image 114 into similarly sized blocks 120. Atblock 604, encoder 112 classifies, based on statistical characteristicsof each segmented block 120, each block 120 as a respective block type.At block 606, encoder 112 selects a particular encoding algorithm toencode the block 120 based on quality parameters associated with theblock type, a total rate constraint, and acceptable distortion. At block608, encoder 112 encodes each block 120 of the digital image 114 basedon the corresponding selected encoding algorithm to generate acompressed image 116. At block 610, the compressed image 116 is decodedby a decoder 118 in view of information encapsulated by the compressedimage 116 for presentation (e.g., via a display 128 of FIG. 1) to auser. Such information includes, for example, an indication of theparticular encoding algorithm used to encode each block 120, a colorindex, etc.

CONCLUSION

Although the systems and methods for block-based fast image compressionhave been described in language specific to structural features and/ormethodological operations or actions, it is understood that theimplementations defined in the appended claims are not necessarilylimited to the specific features or actions described. For example,although system 100 of FIG. 1 has been described with respect toencoding compound images, system 100 can also be used to encodenon-compound images. In such a scenario, a non-compound image may haveonly blocks 120 classified as text, or some combination of pictureand/or smooth, and no hybrid content. In view of this, the specificfeatures and operations of system 100 are disclosed as exemplary formsof implementing the claimed subject matter.

1. A computer-implemented method comprising: segmenting a digital imageinto multiple blocks; for each block of the multiple blocks, identifyinga respective set of statistical characteristics of the block; andencoding each block of the multiple blocks with a particular encodingalgorithm of multiple encoding algorithms, the particular encodingalgorithm being selected at least based on statistical characteristicsof the block.
 2. The method of claim 1, wherein block size of respectiveones of the multiple blocks is arbitrary and variable.
 3. The method ofclaim 1, wherein the statistical characteristics indicate that the blockis a smooth block, and wherein the encoding further comprises quantizingall colors in the smooth block to a most frequent color.
 4. The methodof claim 1, wherein the statistical characteristics indicate that theblock is a text block, and wherein the encoding further comprises:quantizing colors within a given distance threshold to major colors tocorresponding major colors; converting pixels in the text block to indexvalues; and for each pixel of the pixels: generating a context for thepixel based on pixel neighbors; and coding the pixel using the context.5. The method of claim 1, wherein the statistical characteristicsindicate that the block is a hybrid block, and wherein the encodingfurther comprises: separating text and pictures in the block intodifferent layers; and independently coding each layer of the layers. 6.The method of claim 1, wherein the particular encoding algorithm isselected in view of a quality-weight factor that are evaluated in viewof a total rate constraint and weighted distortion, the quality-weightfactor being determined from the statistical characteristics thatindicate block type, the total rate constraint being a function of thetotal numbers of hybrid and picture blocks in the digital image.
 7. Themethod of claim 1, wherein identifying the respective set of statisticalcharacteristics for the block further comprises: calculating gradientsfor least a subset of pixels comprising the block; generating a gradienthistogram from the gradients; and classifying the block as a smoothblock, text block, picture block, or hybrid block based on gradientdistributions associated with the gradient histogram.
 8. The method ofclaim 7, wherein a gradient of the gradients represents an absolutedifference between a pixel and a neighboring pixel.
 9. The method ofclaim 7, wherein generating the gradient histogram further comprises:thresholding the gradients to identify distributions of the gradients;and creating the gradient histogram in view of pixel counts associatedwith the distributions.
 10. The method of claim 9, wherein thresholdingclassifies the gradients into one or more of a low-gradient class, amid-gradient class, and a high-gradient class.
 11. A computer-readablestorage medium comprising computer-program instructions that whenexecuted by a processor perform operations comprising: accessing acompressed image, the compressed image being comprised of multipleencoded block segments, each block of the multiple encoded blocksegments being encoded with a particular encoding algorithm of multipleencoding algorithms, the particular encoding algorithm used to encodethe block being based at least on statistical characteristics associatedwith original digital image content of the block, the statisticalcharacteristics indicating that the block is one of a smooth block, atext block, a picture block, and a hybrid block; and decoding thecompressed image.
 12. The computer-readable storage medium of claim 11,wherein the statistical characteristics for the block are based ondistributions of gradients calculated for at least a subset of pixelscomprising the block.
 13. The computer-readable storage medium of claim11, wherein the statistical characteristics for the block are based ondistributions of gradients calculated for at least a subset of pixelscomprising the block, each gradient of the gradients representing anabsolute difference between a pixel and a neighboring pixel.
 14. Thecomputer-readable storage medium of claim 11, wherein the statisticalcharacteristics for the block are based on distributions of gradientscalculated for at least a subset of pixels comprising the block, thedistributions being based on respective ones of the gradients beingclassified into one or more of a low-gradient class, a mid-gradientclass, and a high-gradient class.
 15. The computer-readable storagemedium of claim 11, wherein the statistical characteristics indicatethat the block is a smooth block, and wherein all colors encoded in thesmooth block were quantized to a most frequent color.
 16. Thecomputer-readable storage medium of claim 11, wherein the statisticalcharacteristics indicate that the block is a text block, and wherein:colors in the block within a given distance threshold to major colorshave been quantized to corresponding major colors; pixels in the blockhave been converted to index values; and wherein the computer-programinstructions for decoding further comprise: for each pixel of thepixels, decoding the pixel in view of a corresponding value of the indexvalues and a context generated from pixels neighboring the pixel. 17.The computer-readable storage medium of claim 11, wherein thestatistical characteristics indicate that the block is a hybrid block,and wherein different layers respectively represent text and pictures inthe block; and wherein the computer-program instructions for decodingfurther comprise instructions for independently decoding each layer ofthe layers.
 18. A computing device comprising: a processor; and a memorycouple to the processor, memory comprising computer-program instructionsexecutable by the processor for: segmenting a digital image intomultiple blocks; for each block of the multiple blocks, identifying arespective set of statistical characteristics of the block; encodingeach block of the multiple blocks with a particular encoding algorithmof multiple encoding algorithms, the particular encoding algorithm beingselected based at least on statistical characteristics of the block; andwherein the statistical characteristics indicate that the block is asmooth block, and wherein the computer-program instructions for encodingfurther comprises instructions for quantizing all colors in the smoothblock to a most frequent color.
 19. The computing device of claim 18,wherein the particular encoding algorithm is selected in view of aquality-weight factor that are evaluated in view of a total rateconstraint and weighted distortion, the quality-weight factor beingdetermined from the statistical characteristics that indicate blocktype, the total rate constraint being a function of the total numbers ofhybrid and picture blocks in the digital image
 20. The computing deviceof claim 18, wherein the computer-program instructions for identifyingthe respective set of statistical characteristics for the block furthercomprise instructions for: calculating gradients for least a subset ofpixels comprising the block; generating a gradient histogram from thegradients; and classifying the block as a smooth block, text block,picture block, or hybrid block based on gradient distributionsassociated with the gradient histogram.